﻿using System.Collections.Generic;
using OilRigSumoWrestlers.Entities.MenuItems;
using RaptorEngine;

namespace OilRigSumoWrestlers.Scenes.Menu
{
    public abstract class MenuScene:Scene
    {
        protected List<MenuItem> _menuItems = new List<MenuItem>();
        protected int _selectedItem = 0;

        public MenuScene(bool network) : base(network)
        {
            
        }

        public void GoForward()
        {
            GameEngine.Instance.Audio.PlaySound("menu_forward", .5f);
            _menuItems[_selectedItem].Execute();
        }

        public virtual void GoBack() 
        {
            GameEngine.Instance.Audio.PlaySound("menu_back", .5f);
        }

        public void SelectNext()
        {
            GameEngine.Instance.Audio.PlaySound("menu_select", .1f);
            _menuItems[_selectedItem].Deselect();
            _selectedItem++;
            if (_selectedItem == _menuItems.Count)
                _selectedItem = 0;
            _menuItems[_selectedItem].Select();
        }

        public void SelectPrevious()
        {
            GameEngine.Instance.Audio.PlaySound("menu_select", .1f);
            _menuItems[_selectedItem].Deselect();
            _selectedItem--;
            if (_selectedItem < 0)
                _selectedItem = _menuItems.Count - 1;
            _menuItems[_selectedItem].Select();
        }

        public override void Update(){}
    }
}
